package com.lagou.module4hw.hw56.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.LinkedList;
import java.util.List;

/**
 * 服务器
 */
public class Server {
    //保存所有的socket
    public volatile static List<Socket> socketList = new LinkedList<>();

    //锁
    public static Object lock = new Object();

    public static void main(String[] args) {

        ServerSocket ss = null;
        try {
            ss = new ServerSocket(8889);
            while(true) {
                Socket socket = ss.accept();
                socketList.add(socket);
                new Thread(new ServerReceive(socket)).start();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
